require "Battle/Entity/Entity"
require "Battle/Editor/EditorEntity"
require "Battle/Entity/EntityInfo"
require "Battle/Manager/FightManager"
require "ClientFight/xiaoniu/fszx/ClientFightDefine"
SkillRoleMgr = {};
local this = SkillRoleMgr;

local tab_Entity = {};
local fightTimer = nil;
local leftRole;
local rightRole;
local leftRoleInfo = nil;
local rightRoleInfo = nil;
local curSkillId = 0;
local curSkillData = nil;
local canAttack = false;
local cdAttack = false;
local battleRoundRoot = nil;
local CameraRound;

local roles;
local screenEff;
local skilllist;

local leftPosition;
local rightPosition;

local idxToFightId = {};
this.report = {}
this.savePathFiles = nil;
this.saveReportFile = nil;
this.isShowSaveReport = false;
this.isShowTxtReport = false;---开启文字战报
this.showTxtReport = "";
function SkillRoleMgr.init()
    battleRoundRoot = panelMgr.BattleRound;
    battleRoundRoot.gameObject:SetActive(true);
    CameraRound = battleRoundRoot.transform:Find("CameraRound"):GetComponent("Camera");
    FightManager.setCamera(CameraRound);
    Util.resetRandomFac(999999);
    --FightManager.fight = Fight:new();
    EnumConst.FIGHT_INNER_ROUND = decodeJsonStrToTabel(G.dataTable["t_global"]["54"].f_string_value);
    EnumConst.FIGHT_OUTER_ROUND = decodeJsonStrToTabel(G.dataTable["t_global"]["55"].f_string_value);
    EnumConst.FIGHT_INNER_ROUND0 = decodeJsonStrToTabel(G.dataTable["t_global"]["62"].f_string_value);

    leftPosition = decodeJsonStrToTabel(G.dataTable["t_global"]["1"].f_string_value);
    rightPosition = decodeJsonStrToTabel(G.dataTable["t_global"]["4"].f_string_value);
    --printTable(rightPosition);
    logicMgr.MapManager.setMapId(0);
    --FightManager.isEdit = false;
end

function SkillRoleMgr.playSkills(skillInfo)
    local list = {};
    local fighterId = 1;

    local leftCount = skillInfo:getLeftModelIdsCount();
    local rightCount = skillInfo:getRightModelIdsCount();
    local skillCount = skillInfo:getSkillIdsCount();
    local delayCount = skillInfo:getSkillIdDelaysCount();
    local fighterIndex = skillInfo.fighterIndex;
    if fighterIndex <= 0 then
        fighterIndex = 1;
    end

    for i = 0, leftCount - 1 do
        if skillInfo.leftModelIds[i] > 0 then
            local command = {};
            command["1"] = 0;
            command["2"] = EnumConst.FightActionType.INIT;
            command["3"] = 0;
            command["4"] = {};
            command["4"]["1"] = skillInfo.leftFighterIds[i];
            command["4"]["2"] = skillInfo.leftModelIds[i];
            command["4"]["3"] = 1000;
            command["4"]["4"] = 1000;
            command["4"]["5"] = 100;
            command["4"]["6"] = 100;
            command["4"]["7"] = 0;
            command["4"]["8"] = {};
            command["4"]["8"]["1"] = leftPosition[i + 1][1];
            command["4"]["8"]["2"] = leftPosition[i + 1][3];
            table.insert(list, command);
            fighterId = fighterId + 1;
        end
    end
    for i = 0, rightCount - 1 do
        if skillInfo.rightModelIds[i] > 0 then
            local command = {};
            command["1"] = 0;
            command["2"] = EnumConst.FightActionType.INIT;
            command["3"] = 0;
            command["4"] = {};
            command["4"]["1"] = skillInfo.rightFighterIds[i];
            command["4"]["2"] = skillInfo.rightModelIds[i];
            command["4"]["3"] = 1000;
            command["4"]["4"] = 1000;
            command["4"]["5"] = 100;
            command["4"]["6"] = 100;
            command["4"]["7"] = 1;
            command["4"]["8"] = {};
            command["4"]["8"]["1"] = rightPosition[i + 1][1];
            command["4"]["8"]["2"] = rightPosition[i + 1][3];
            table.insert(list, command);
            fighterId = fighterId + 1;
        end
    end

    local mainSkill = skillInfo.skillIds[0];
    local fighterId = skillInfo.leftFighterIds[fighterIndex - 1];
    local targetId = skillInfo.targetIndexs[0];
    --log("fighterId:"..fighterId)
    --log("targetId:"..targetId)

    if skillCount > 0 then
        local beginTime = 10;
        if mainSkill ~= nil and mainSkill > 0 then
            local skillShow = decodeJsonStrToTabel(skillInfo.skillShows[0]);
            local skillData = decodeJsonStrToTabel(skillInfo.skillDatas[0]);

            local rangeLimit = decodeJsonStrToTabel(Entity:GetTableValue(skillData, "f_RangeLimit"));
            if rangeLimit == nil then
                rangeLimit = {};
                rangeLimit[1] = 10;
                rangeLimit[2] = 10;
            end
            local skillRange_x = tonumber(rangeLimit[1] / 2);
            local skillRange_y = tonumber(rangeLimit[2] / 2);
            local rolePos = leftPosition[fighterIndex];
            local targetPos;
            if targetId > 5 then
                targetPos = rightPosition[targetId - 5];
            else
                targetPos = leftPosition[targetId];
            end
            if (Mathf.Abs(rolePos[1] - targetPos[1]) > skillRange_x + 0.5) or (Mathf.Abs(rolePos[3] - targetPos[3]) > skillRange_y + 0.5) then
                local x = rolePos[1];
                local y = rolePos[3];
                if Mathf.Abs(rolePos[1] - targetPos[1]) > skillRange_x + 0.5 then
                    if targetPos[1] - rolePos[1] > 0 then
                        x = rolePos[1] + (Mathf.Abs(targetPos[1] - rolePos[1]) - skillRange_x - 0.5);
                    else
                        x = rolePos[1] - (Mathf.Abs(targetPos[1] - rolePos[1]) - skillRange_x - 0.5);
                    end
                end
                if Mathf.Abs(rolePos[3] - targetPos[3]) > skillRange_y + 0.5 then
                    if targetPos[3] - rolePos[3] > 0 then
                        y = rolePos[3] + (Mathf.Abs(targetPos[3] - rolePos[3]) - skillRange_y - 0.5);
                    else
                        y = rolePos[3] - (Mathf.Abs(targetPos[3] - rolePos[3]) - skillRange_y - 0.5);
                    end
                end
                local command = {};
                command["1"] = beginTime;
                command["2"] = EnumConst.FightActionType.MOVE;
                command["3"] = 0;
                command["4"] = {};
                command["4"]["1"] = fighterId;
                command["4"]["2"] = 0;
                command["4"]["3"] = {};
                command["4"]["3"]["x"] = x;
                command["4"]["3"]["y"] = y;
                table.insert(list, command);
                beginTime = beginTime + 50;
            end

            local command = {};
            command["1"] = beginTime;
            command["2"] = EnumConst.FightActionType.ATTACK;
            command["3"] = 0;
            command["4"] = {};
            command["4"]["1"] = fighterId;
            command["4"]["2"] = targetId;
            command["4"]["3"] = mainSkill;
            command["4"]["6"] = skillShow;
            table.insert(list, command);

            if skillShow.f_HitFResource ~= nil and skillShow.f_HitFResource ~= "" and skillShow.f_HitFName ~= nil and skillShow.f_HitFName ~= "" then
                local command = {};
                command["1"] = beginTime;
                command["2"] = EnumConst.FightActionType.HIT;
                command["3"] = 0;
                command["4"] = {};
                command["4"]["1"] = fighterId;
                command["4"]["2"] = targetId;
                command["4"]["3"] = mainSkill;
                command["4"]["4"] = skillShow;
                table.insert(list, command);
            end
        end
        --log(skillCount);
        for i = 1, skillCount - 1 do
            local skillId = skillInfo.skillIds[i];
            local delay = Mathf.Floor(toNumber(skillInfo.skillIdDelays[i]) / EnumConst.FIGHT_FRAME);

            if skillId ~= nil and skillId > 0 and delay ~= nil then
                local skillShow = decodeJsonStrToTabel(skillInfo.skillShows[i]);
                local command = nil;
                if skillShow.f_FlyFResource ~= nil and skillShow.f_FlyFResource ~= "" and skillShow.f_FlyFName ~= nil and skillShow.f_FlyFName ~= "" then
                    command = this.createFly(beginTime + delay, fighterId, targetId, skillId, skillShow);
                else
                    command = this.createAttack(beginTime + delay, fighterId, targetId, skillId, skillShow);
                end
                if command ~= nil then
                    table.insert(list, command);
                end

                if skillShow.f_HitFResource ~= nil and skillShow.f_HitFResource ~= "" and skillShow.f_HitFName ~= nil and skillShow.f_HitFName ~= "" then
                    local command = {};
                    command["1"] = beginTime;
                    command["2"] = EnumConst.FightActionType.HIT;
                    command["3"] = 0;
                    command["4"] = {};
                    command["4"]["1"] = fighterId;
                    command["4"]["2"] = targetId;
                    command["4"]["3"] = mainSkill;
                    command["4"]["4"] = skillShow;
                    table.insert(list, command);
                end
            end
        end
        --模拟伤害
        for i = 0, skillCount - 1 do
            local skillId = skillInfo.skillIds[i];
            for i = 1, 100 do
                local command = {};
                command["1"] = beginTime + i * 10;
                command["2"] = EnumConst.FightActionType.DAMAGE;
                command["3"] = 0;
                command["4"] = {};
                command["4"]["1"] = fighterId;
                command["4"]["2"] = targetId;
                command["4"]["3"] = 100 + i;
                command["4"]["4"] = Config.damageType.normal;
                command["4"]["5"] = skillId;
                table.insert(list, command);
            end
        end
    end

    local command = {};
    command["1"] = 10000;
    command["2"] = EnumConst.FightActionType.END;
    table.insert(list, command);

    if FightManager.hasInit then
        FightManager.stopCommand();
        FightManager.destroy();
    end

    FightManager.init();
    FightManager.readReport(list, EnumConst.FightTypeConst.DUNGEON);
    showUI(PanelNames.UILoadingBattle, FightManager.resList, function()
        -- Util.WaitForSeconds(function ()
        --     DestoryUI(PanelNames.UILoadingBattle);
        --     hideOtherUI(true);
        --     showUI(PanelNames.UIBattleMain);
        --     FightManager.entrance();
        -- end,0.5);
        utimer.delayCall(function()
            DestoryUI(PanelNames.UILoadingBattle)
            hideOtherUI(true)
            showUI(PanelNames.UIBattleMain)
            FightManager.entrance()
        end, 500)
    end);
end

function SkillRoleMgr.createAttack(frame, fighterId, targetId, skillId, skillShow)
    local command = {};
    command["1"] = frame;
    command["2"] = EnumConst.FightActionType.ATTACK;
    command["3"] = 0;
    command["4"] = {};
    command["4"]["1"] = fighterId;
    command["4"]["2"] = targetId;
    command["4"]["3"] = skillId;
    command["4"]["4"] = skillShow;
    return command;
end

function SkillRoleMgr.createFly(frame, fighterId, targetId, skillId, skillShow)
    local command = {};
    command["1"] = frame;
    command["2"] = EnumConst.FightActionType.FLY;
    command["3"] = 0;
    command["4"] = {};
    command["4"]["1"] = fighterId;
    command["4"]["2"] = targetId;
    command["4"]["3"] = skillId;
    command["4"]["4"] = skillShow;
    return command;
end

function SkillRoleMgr.fightReportHead()
    local report = {};
    local action = {};
    action["action"] = "init";
    action["fight"] = {};
    action["fight"]["fightId"] = "1_1_999999999";
    action["fight"]["frame"] = 0;
    action["fight"]["randomSeed"] = "999999999999999";
    action["fight"]["teams"] = {};

    local team1 = FightTeam.New();
    team1.teamIndex = 1;
    local team2 = FightTeam.New();
    team2.teamIndex = 2;
    table.insert(action["fight"]["teams"], team1);
    table.insert(action["fight"]["teams"], team2);

    table.insert(team1.fighters, leftRoleInfo);
    table.insert(team2.fighters, rightRoleInfo);
    table.insert(report, action);

    local action_end = {};
    action_end["action"] = "end";
    action_end["fight"] = {};
    action_end["fight"]["fightId"] = "1_1_999999999";
    action_end["fight"]["frame"] = 100;
    action_end["fight"]["randomSeed"] = "999999999999999";
    action_end["fight"]["teams"] = {};
    table.insert(report, action_end);

    return report;
end

function SkillRoleMgr.fightReportEnd()
    return report;
end

function SkillRoleMgr.playSkill(skillId, skillCfgData, skillShowCfg)
    curSkillData = decodeJsonStrToTabel(skillCfgData);
    curSkillShow = decodeJsonStrToTabel(skillShowCfg);
    curSkillId = skillId;

    leftRole:setActive(false);
    rightRole:setActive(false);

    if FightManager.hasStart() == true then
        --log("FightManager.hasStart");
        FightManager.closeFight();
    end
    local report = this.fightReportHead();

    local action_move = {};
    action_move["action"] = "move";
    action_move["frame"] = 1;
    action_move["fighterId"] = leftRoleInfo.fighterId;
    action_move["targetId"] = rightRoleInfo.fighterId;
    table.insert(report, action_move);

    local rangeLimit = decodeJsonStrToTabel(Entity:GetTableValue(curSkillData, "f_RangeLimit"));
    if rangeLimit == nil then
        rangeLimit = {};
        rangeLimit[1] = 10;
    end
    local skillRange = tonumber(rangeLimit[1] / 2);
    local rolePos = leftRole.position;
    local targetPos = rightRole.position;
    local dis = Vector2.Distance(rolePos, targetPos);

    local frame = math.ceil((dis - (skillRange + rightRole.shape.x) / 2) / leftRoleInfo.moveSpeed * 1000 / EnumConst.FIGHT_FRAME);
    if frame < 0 then
        frame = 0;
    end
    local action_stop = {};
    action_stop["action"] = "stop";
    action_stop["frame"] = 1 + frame;
    action_stop["fighterId"] = leftRoleInfo.fighterId;
    table.insert(report, action_stop);

    local action_attack = {};
    action_attack["action"] = "attack";
    action_attack["frame"] = 2 + frame;
    action_attack["fighterId"] = leftRoleInfo.fighterId;
    action_attack["targetId"] = rightRoleInfo.fighterId;
    action_attack["skillId"] = skillId;
    table.insert(report, action_attack);

    local fightreport = getJsonStr(report);
    --log(fightreport);
    FightManager.initReport(fightreport, EnumConst.FightTypeConst.DUNGEON);
    FightManager.fightResult = 0;
    FightSkillManager.setEditSkill(curSkillData, curSkillShow);

    showUI(PanelNames.UILoadingBattle, FightManager.resList, function()
        -- Util.WaitForSeconds(function ()
        --     DestoryUI(PanelNames.UILoadingBattle);
        --     hideOtherUI(true);
        --     showUI(PanelNames.UIBattleMain);
        --     FightManager.entrance();
        -- end,0.5);
        utimer.delayCall(function()
            DestoryUI(PanelNames.UILoadingBattle)
            hideOtherUI(true)
            showUI(PanelNames.UIBattleMain)
            FightManager.entrance()
        end, 500)
    end);

end

function SkillRoleMgr.checkAttackState()
    return canAttack;
end

local cacheVec1 = Vector3(0, 0, 0)
local cacheVec2 = Vector3(0, 0, 0)
function SkillRoleMgr.checkAttackDistance()
    local rangeLimit = decodeJsonStrToTabel(Entity:GetTableValue(curSkillData, "f_RangeLimit"));
    local skillRange = tonumber(rangeLimit[1] / 2);
    cacheVec1.x, cacheVec1.y, cacheVec1.z = Util.Lua_GetLocalPositionXYZ(leftRole:getModel().transform, 0, 0, 0)
    cacheVec2.x, cacheVec1.y, cacheVec2.z = Util.Lua_GetLocalPositionXYZ(rightRole:getModel().transform, 0, 0, 0)
    local dis = Vector3.Distance(cacheVec1, cacheVec2);
    if dis > (skillRange + rightRole.shape.x) / 2 then
        return false;
    else
        return true;
    end
end

function SkillRoleMgr.useSkill()
    --log("useSkill")
    if cdAttack then
        return ;
    end
    cdAttack = true;
    leftRole:beginAttack(curSkillId, curSkillData, curSkillShow, rightRole);
    canAttack = false;
    local guideTime = Entity:GetTableValue(curSkillData, "f_GuideTime");
    -- Util.WaitForSeconds(function ()
    --     cdAttack = false;
    -- end, tonumber(guideTime/1000));
    utimer.delayCall(function()
        cdAttack = false
    end, tonumber(guideTime))
end

function SkillRoleMgr.stopplaySkill()

    if leftrole ~= nil then
        leftrole:stopAttackCoroutine();
    end

end

function SkillRoleMgr.ShakeCamera(shakeTime, delayTime, shaketype, shakeStrength, shakePower)
    if this.shakeCamera == nil then
        this.shakeCamera = CameraRound.transform:GetComponent("CameraShake");
    end
    this.shakeCamera:StartShake(shakeTime, delayTime, Vector3(1, 1, 0), shaketype, shakeStrength, shakePower);
end

function SkillRoleMgr.ZoomCamera(target, time, delayTime, backtime, movedist)
    if this.shakeCamera == nil then
        this.shakeCamera = CameraRound.transform:GetComponent("CameraShake");
    end

    this.shakeCamera:StartZoomIn(time, target, delayTime, backtime, movedist);
end

function SkillRoleMgr.FadeBackground(delaytime, time, targetvalue, pausetime, backtime)
    if this.shakeCamera == nil then
        this.shakeCamera = CameraRound.transform:GetComponent("CameraShake");
    end

    this.shakeCamera:StartFadeBgImage(delaytime, time, targetvalue, pausetime, backtime);
end

function SkillRoleMgr.SlowFrameScle(delaytime, time, targetvalue, pausetime, backtime, backvalue)
    if this.shakeCamera == nil then
        this.shakeCamera = CameraRound.transform:GetComponent("CameraShake");
    end

    this.shakeCamera:StartScaleTime(delaytime, time, targetvalue, pausetime, backtime, backvalue);
end

function SkillRoleMgr.ShowScreenEffect()

    if screenEff ~= nil then
        screenEff:GetComponent("ParticleSystem"):Play();
        return ;
    end
    resMgr:LoadPrefab("Prefabs/Skill/EFF_pingmudaoguang", function(eff)

        screenEff = newObject(eff);
        screenEff.transform:SetParent(CameraRound.transform);
        Util.Lua_SetLocalPositionXYZ(screenEff, 0, 0, 0)
        Util.Lua_SetLocalScaleXYZ(screenEff, 1, 1, 1);
        Util.Lua_SetLocalRotationXYZ(screenEff, 40, 0, 0)
    end);

end

function SkillRoleMgr.addBuff(buffid, buffcfgdata, leftroleobj, rightroleobj)

    local newbuffdata = json.decode(buffcfgdata);
    local buffround = G.dataTable["T_buff"][buffid];

    buffround["f_BuffName"] = newbuffdata["f_BuffName"];
    buffround["f_BuffVEXResource"] = newbuffdata["f_BuffVEXResource"];
    buffround["f_BuffVEXContinuity"] = newbuffdata["f_BuffVEXContinuity"];
    buffround["f_BuffVEXDuration"] = newbuffdata["f_BuffVEXDuration"];
    buffround["f_BuffVEXPosition"] = newbuffdata["f_BuffVEXPosition"];
    buffround["f_BuffVEXScale"] = newbuffdata["f_BuffVEXScale"];
    buffround["f_BuffVEXRotation"] = newbuffdata["f_BuffVEXRotation"];
    buffround["f_BuffAction"] = newbuffdata["f_BuffAction"];

    local leftplayerinfo = {};
    leftplayerinfo.Id = 168;
    leftplayerinfo.combatIndex = 1;
    leftplayerinfo.combatType = 0;
    leftplayerinfo.hp = 100;
    leftplayerinfo.isBoss = false;
    leftplayerinfo.isPlayer = true;
    leftplayerinfo.lv = 10;
    leftplayerinfo.modFile = modelfile;
    leftplayerinfo.mp = 100;
    leftplayerinfo.name = "继刚";

    local righttplayerinfo = {};
    righttplayerinfo.Id = 1901;
    righttplayerinfo.combatIndex = 50;
    righttplayerinfo.combatType = 1;
    righttplayerinfo.hp = 100;
    righttplayerinfo.isBoss = true;
    righttplayerinfo.isPlayer = false;
    righttplayerinfo.lv = 10;
    righttplayerinfo.modFile = "2030";
    righttplayerinfo.mp = 100;
    righttplayerinfo.name = "梅菲特";

    leftrole = EditorRole.New(leftroleobj, leftplayerinfo)
    rightrole = EditorRole.New(rightroleobj, righttplayerinfo)
    roles = {};
    roles[0] = leftrole;
    roles[50] = rightrole;

    leftrole:AddBuff(buffid, leftroleobj, rightroleobj);

    if fightTimer == nil then
        fightTimer = Timer.New(this.onFrameRender, 0.05, 9999, false);
    else
        fightTimer:Reset(this.onFrameRender, 0.05, 9999, false);
    end
    fightTimer:Start();

end

function SkillRoleMgr.playReport(filepath, savePath)
    --log(filepath);
    local fightreport = {};

    if this.isShowSaveReport then
        this.saveFilePath = savePath .. "/" .. os.time();
        local SimulatorTest = ClientFight.SimulatorTest.New()
        SimulatorTest:test();
    else
        local file = io.open(filepath, "r");
        local report = file:read();
        io.close(file);
        fightreport = decodeJsonStrToTabel(report);
    end

    --log(report);
    if FightManager.hasInit then
        FightManager.stopCommand();
        FightManager.destroy();
    end

    FightManager.init();
    FightManager.readReport(fightreport, EnumConst.FightTypeConst.DUNGEON);
    showUI(PanelNames.UILoadingBattle, FightManager.resList, function()
        -- Util.WaitForSeconds(function ()
        --     DestoryUI(PanelNames.UILoadingBattle);
        --     DestoryUI(PanelNames.UILogin);
        --     hideOtherUI(true);
        --     showUI(PanelNames.UIBattleMain);
        --     FightManager.entrance();
        -- end,0.5);
        utimer.delayCall(function()
            DestoryUI(PanelNames.UILoadingBattle)
            DestoryUI(PanelNames.UILogin)
            hideOtherUI(true)
            showUI(PanelNames.UIBattleMain)
            FightManager.entrance()
        end, 500)
    end);
end
--保存战报
function SkillRoleMgr.doEndSavePathFile()
    if this.isShowSaveReport then
        fightreport = this.report
        local strReport = getJsonStr(this.report)
        --if this.savePathFiles then
        --    io.close(this.savePathFiles);
        --    this.savePathFiles = nil;
        --end
        --if this.saveReportFile then
        --    io.close(this.saveReportFile)
        --    this.saveReportFile = nil;
        --end
        local savePathStr = this.saveFilePath .. ".log";
        local file = io.open(savePathStr, "w+");
        io.output(file)
        io.write(strReport)
        file.close();
        local path = this.saveFilePath .. "_txt" .. ".txt";
        local savePathFiles = io.open(path, "w+");
        io.output(savePathFiles)
        io.write(this.showTxtReport)
        savePathFiles.close();
        --utimer.delayCall(function ()
        --end,5000)

        --io.close(this.saveReportFile );
        --this.saveReportFile = nil;

    end

end

--保存文字战报
function SkillRoleMgr.savePathFile(strReport)
    if not this.isShowTxtReport then
        return ;
    end
    if not this.isShowSaveReport then
        return ;
    end
    --logError(strReport)
    this.showTxtReport = this.showTxtReport .. strReport .. "\n";
end

function SkillRoleMgr.getAllEntityName(teamIdx)
    idxToFightId[teamIdx] = {}
    local fighterMap = FightManager.fighterMap;
    local fighterName = "";
    local count = 1;
    for i, v in ipairs(fighterMap) do
        if v.name and v.teamIndex == teamIdx then
            idxToFightId[teamIdx][count] = v.fighterId;
            fighterName = fighterName .. v.name .. (v.isHero and "(英雄)" or "(召唤物)") .. " " .. v.fighterId .. ",";
            count = count + 1;
        end
    end
    return fighterName;
end
function SkillRoleMgr.getEntityAttribute(teamIdx, heroIdx)
    local attributeStr = "";
    if idxToFightId[teamIdx] then
        local fightId = idxToFightId[teamIdx][heroIdx];
        local fighter = FightManager.fighterMap[fightId];
        if fighter then
            attributeStr = attributeStr .. "血量" .. fighter.hp .. "/" .. fighter.maxHP .. " \n";
            attributeStr = attributeStr .. "能量" .. fighter.energy .. "/" .. fighter.maxEnergy .. " \n";
            attributeStr = attributeStr .. "护盾" .. fighter.shield .. ",";
        end
    end
    return attributeStr;
end
function SkillRoleMgr.getEntityFightInfoStr(teamIdx, heroIdx)
    if idxToFightId[teamIdx] then
        local fightId = idxToFightId[teamIdx][heroIdx];
        local fighter = FightManager.fighterMap[fightId];
        if fighter then
            local str = fighter.battleInfoStr
            return str;
        end
    end
    return "";
end

function SkillRoleMgr.setBattleInfo(is)
    FightManager.isShowBattleInfo = is == 1;
end
function SkillRoleMgr.setSaveReport(is)
    this.isShowSaveReport = is == 1;
    logicMgr.FightSelect.setIsShowSaveReport(this.isShowSaveReport)
end

return SkillRoleMgr;